#include <iostream>
#include <memory>
class Girl; 
class Boy
{
public:
    Boy(){std::cout<<"Boy构造\n";}
    ~Boy(){std::cout<<"BOy析构\n";}
    void SetGirlFirend(std::shared_ptr<Girl> &girl)
    {
        this->Girlfriend = girl;
    }
private:
    std::weak_ptr<Girl> Girlfriend;
};

class Girl
{
public:
    Girl(){std::cout<<"Girl构造\n";}
    ~Girl(){std::cout<<"Girl析构\n";}
    void SetBoyFirend(std::shared_ptr<Boy> &Boy)
    {
        this->Boyfriend = Boy;
    }
private:
    std::weak_ptr<Boy> Boyfriend;
};

int main()
{
    std::shared_ptr<Boy> b = std::make_shared<Boy>();
    std::shared_ptr<Girl> g = std::make_shared<Girl>();
    
    //解决共享指针的循环引用问题
    b->SetGirlFirend(g);
    g->SetBoyFirend(b);

    //类的内部  不要放共享指针， 要么用独占或者弱

    return 0;
}